//
//  HZStatus.swift
//  555wobo
//
//  Created by 黄某某 on 15/12/21.
//  Copyright © 2015年 黄某某. All rights reserved.
//

import UIKit

class HZStatus: NSObject {

    var created_at : String?
    var id : Int64 = 0
    var text : String?
    var source : String?
    var pic_urls:[[String: AnyObject]]?
    var reposts_count : Int = 0
    var comment_count : Int = 0
    var attitudes_count :Int = 0
    
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    override var description: String {
        let prop = ["created_at","id","text","source","pic_urls","reposts_count","comment_count","attitudes_count"]
        let dict = dictionaryWithValuesForKeys(prop)
        return "\n\t微博模型: \(dict)"
    }
    class func mLoadStatus(finished: (statuses: [HZStatus]?, error: NSError?) -> ()) {
        HZNetworking.sharedInstance.loadStatus { (result, error) -> () in
            if error != nil || result == nil{
                finished(statuses: nil, error: error)
                return
            }
            if let array = result?["statuses"] as? [[String: AnyObject]]{
                var statuses = [HZStatus]()
                for dict in array{
                    let status = HZStatus(dict: dict)
                    statuses.append(status)
                    
                }
                finished(statuses: statuses, error: nil)
            }else{
                finished(statuses: nil, error: error)
            }
        }
    }
    
}
